<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ui_Form.aspx.cs" Inherits="Private_Config_Scheduled_ui_Form" %>
<%@ Register TagPrefix="Flux" Namespace="Deepcode.Flux.Core.UI.Controls" Assembly="Deepcode.Flux.Core" %>
<html>
<head runat="server">
	<link href="../../../Asset/Style/GeneralStyle.css" rel="stylesheet" type="text/css" />
</head>
<body class="nopad">
<form id="form1" runat="server">
<Flux:HostTable runat="server">

<Flux:ValidationSummarySection runat="server" HeaderText="Please correct the following errors"/>
<Flux:Section runat="server" Title="Add/Edit Scheduled Task">
<Flux:ShadePadBox runat="server">
	<table cellspacing="0" cellpadding="5" border="0" width="500">
	<tr><td nowrap="nowrap">Task Name: <%=Required%></td>
		<td><asp:TextBox Runat="server" ID="TaskName" Width="200px" style="width:200px" MaxLength="200"/></td>
	</tr>
	<tr><td nowrap="nowrap">Execute URL: <%=Required%></td>
		<td><asp:TextBox runat="server" ID="Execute" Width="300px" style="width:300px" MaxLength="500"/></td>
	</tr>
	<tr><td nowrap="nowrap">Next run: <%=Required%></td>
		<td><Flux:DateInput runat="server" ID="ExecuteNext" Type="WITHTIME"/></td>
	</tr>
	</table>
</Flux:ShadePadBox>
</Flux:Section>

<Flux:CollapseSection runat="server" Title="Enable/Disable">
<Flux:ShadePadBox runat="server">
	<table cellspacing="0" cellpadding="5" border="0" width="300">
	<tr><td valign="top">
		Task complete:<br/>
	    <span class="help">
	    Turn this on to disable the task. This will automatically be 
	    turned on when a task has finished it's run cycles.
	    </span>
		</td>
		<td valign="top"><asp:CheckBox runat="server" ID="Finished"/>
		</td>
	</tr>
	</table>		  
</Flux:ShadePadBox>
</Flux:CollapseSection>

<Flux:CollapseSection runat="server" Title="Task Execution">
<Flux:ShadePadBox runat="server">
	<table cellspacing="0" cellpadding="5" border="0" width="500">
	<tr><td nowrap="nowrap">
			<asp:RadioButton runat="server" ID="RunOnce" Text="Run Once only" Checked="true" GroupName="stype" AutoPostBack="true"/>&nbsp;
			<asp:RadioButton runat="server" ID="RunSchedule" Text="Run on a schedule" GroupName="stype" AutoPostBack="true"/>
		</td>
	</tr>
	</table>
</Flux:ShadePadBox>
</Flux:CollapseSection>

<asp:Panel runat="server" ID="PanelSchedule" Visible="false">
<Flux:CollapseSection runat="server" Title="Task schedule">
<Flux:ShadePadBox runat="server">
	<table cellspacing="0" cellpadding="5" border="0" width="500">
	<tr><td nowrap="nowrap">Run Every:</td>
		<td>
			<asp:TextBox runat="server" ID="Interval" Width="100px" style="width:100px" MaxLength="10" Text="1"/>&nbsp;
		    <asp:DropDownList runat="server" ID="Frequency">
				<asp:ListItem Text="Minute(s)" Value="0"/>
				<asp:ListItem Text="Hour(s)" Value="1"/>
				<asp:ListItem Text="Day(s)" Value="2"/>
				<asp:ListItem Text="Month(s)" Value="3"/>
				<asp:ListItem Text="Year(s)" Value="4"/>
			</asp:DropDownList>
		</td>
	</tr>
	
	<tr><td nowrap="nowrap">Runs remaining:</td>
		<td>
			<Flux:Panel runat="server" ID="PanelUnlimitedRuns" Visible="false">
			<asp:TextBox runat="server" ID="TimesRemaining" Width="100px" style="width:100px" MaxLength="10" Text="1"/>&nbsp;
			</Flux:Panel>
			<asp:CheckBox runat="server" ID="TimesUnlimited" Text="Unlimited" AutoPostBack="true" Checked="true"/>
		</td>
	</tr>
	
	<tr><td nowrap="nowrap">Task Expiry:</td>
		<td>
			<Flux:Panel runat="server" ID="PanelExpiry" Visible="false">
			<Flux:DateInput runat="server" ID="ExpireTask" Type="WITHTIME"/>&nbsp;
			</Flux:Panel>
			<asp:CheckBox runat="server" ID="TaskExpires" Text="Task Expires" AutoPostBack="true" Checked="false"/>
		</td>
	</tr>
	</table>
	
</Flux:ShadePadBox>
</Flux:CollapseSection>
</asp:Panel>

<Flux:Section runat="server">
<Flux:PadBox CssClass="Pad5Button" runat="server">
	<asp:Button runat="server" ID="btnSave" Text="Save" OnClick="btnSave_Click"/>&nbsp;&nbsp;&nbsp;
	<asp:Button runat="server" ID="btnCancel" Text="Cancel" OnClick="btnCancel_Click" CausesValidation="False"/>
</Flux:PadBox>
</Flux:Section>

<!-- Validators -->
<asp:RequiredFieldValidator Runat="server" ControlToValidate="TaskName" ErrorMessage="You must specify the name of this user group" Display="None"/>
<asp:RequiredFieldValidator Runat="server" ControlToValidate="Execute" ErrorMessage="You must specify the URL to execute" Display="None"/>
<Flux:DateInputValidator Runat="server" ControlToValidate="ExecuteNext" ErrorMessage="You must specify a valid date and time to run the task" Display="None"/>

<asp:CustomValidator runat="server" ID="ValidateIntervalSet" ControlToValidate="Interval" ErrorMessage="This task has a schedule, you must specify a valid 'Run Every' frequency" Display="none" ValidateEmptyText="true"/>
<asp:CustomValidator runat="server" ID="ValidateTimesRemaining" ControlToValidate="TimesRemaining" ErrorMessage="This task allows only a set number of executions - please specify a valid number of runs remaining" Display="None"  ValidateEmptyText="true"/>
<asp:CustomValidator runat="server" ID="ValidateExpiry" ControlToValidate="ExpireTask" ErrorMessage="This task is set to expire, please provide a valid expiry date and time" Display="none" ValidateEmptyText="true"/>


</Flux:HostTable>
</form>
</body>
</html>
